﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SCO.BE;
using SCO.BL.Interfaces;
using SCO.BL.Service;
using SCO.DAO.Interfaces;
using SCO.DAO.SqlDataAdapter;
using ReportManagement;
namespace AppSCO.Controllers
{
    public class fileController : ReportManagement.PdfViewController
    {
        //
        // GET: /file/

        public ActionResult cita(int Id)
        {
            IDaoFactory daoFactory = new DAOFactory();
            ICitaService citaServices = new CitaService(daoFactory);
            var resultado = citaServices.buscarId(Id);
            var model = new Models.citaDataModel()
            {
                NOMPAC = resultado.NOMPAC,
                APEPPAC = resultado.APEPPAC,
                APEMPAC = resultado.APEMPAC,
                DNIPAC = resultado.DNIPAC,
                FECNACPAC = resultado.FECNACPAC,
                CORPAC = resultado.CORPAC,
                TELCPAC = resultado.TELCPAC,
                TELHPAC = resultado.TELHPAC,
                SEXPAC = resultado.SEXPAC,
                FECCITA = resultado.FECCITA,
                DESHOR = resultado.DESHOR

            };
            return View(model);
        }

        public ActionResult historialPaciente(int Id) {
            IDaoFactory daoFactory = new DAOFactory();
            ICitaService citaServices = new CitaService(daoFactory);
            var entidad = new citaBE() { DNIPAC = "0", NOMPAC = "" };
            var allHistoriasUser = citaServices.datosHistorialUsuario(entidad);
            var datos = allHistoriasUser.Where(c => c.CODCIT == Id).First();
            return View(datos);
        }

        public ActionResult historial(int Id)
        {
            IDaoFactory daoFactory = new DAOFactory();
            ICitaService citaServices = new CitaService(daoFactory);
            var entidad = new citaBE() { DNIPAC = "0", NOMPAC = "" };
            var allHistoriasUser = citaServices.datosHistorialUsuario(entidad);
            var datos = (from c in allHistoriasUser where c.CODCIT == Id select new AppSCO.Models.citaGeneradaDataModel() { 
            DNIPAC = c.DNIPAC,
            NOMPAC = c.NOMPAC,
            APEPPAC = c.APEPPAC,
            APEMPAC = c.APEMPAC,
            DIRPAC = c.DIRPAC,
            TELCPAC = c.TELCPAC,
            TELHPAC = c.TELHPAC,
            CORPAC = c.CORPAC,
            FECCITA  = c.FECCITA,
            DESHOR = c.DESHOR,
            NOMDOC = c.NOMDOC,
            DESLAB = c.DESLAB,
            TIPPAG = c.TIPPAG,
            NUMDOCPAG = c.NUMDOCPAG,
            OBSCIT = c.OBSCIT,
            OBSATEN = c.OBSATEN
            }).ToList(); 
            return View(datos.First());
            //return this.ViewPdf("Resultados", "historial", false, "", datos.First(), "", null, null);
        }

    }
}
